<?php
session_start();
$loginId=$_SESSION['loginid'];
$name=$_SESSION['name'];
$userType=$_SESSION['user_type'];

include("connection/connection.php");
include("config.php");
$critical_vill_id=$_REQUEST['var'];
?>
<html>
<head>
<script language="javascript" type="text/javascript" src="js/validate1.js"></script>
<script language=javascript>
function show_critical(val)
{ 

		if(val == "yes" )
		{
			document.getElementById('crit').style.display = "block";
			document.getElementById('crits').style.display = "none";	
		}
		else
		{
			document.getElementById('crit').style.display = "none";
			document.getElementById('crits').style.display = "block";
			
		/////////////////////////////////////////////////////////////////////		
		var a=document.getElementsByName('CH_quality'+i+'[]')
		a[0].checked=false;
		a[1].checked=false;
		a[2].checked=false;
		a[3].checked=false;
		a[4].checked=false;
		var b=document.getElementsByName('CH_quantity'+i+'[]')
		b[0].checked=false;
		b[1].checked=false;
		b[2].checked=false;
		b[3].checked=false;
		b[4].checked=false;
		///////////////////////////////////////////////////////////////////////
		} 
}
function show_tanker(val,i)
{
//alert(val);
		if(val == "yes" )
		{
			document.getElementById('tanker').style.display = "block";	
		}
		else
		{
			var num = document.getElementById('habcount').value;
			document.getElementById('tanker').style.display = "none";
			for(i=1; i<=num; i++)
			{
			document.getElementById('water_supply_no'+i).value="";
			document.getElementById('water_supply_qty'+i).value="";
			document.getElementById('water_supply_area'+i).value="";
			}
		}
}


function sec6_val(){

if(document.getElementById("critical_yes").checked){

	var all_check = document.getElementsByName("CH_quality[]");
	var count_check=0;
	for (var i = 0; i < all_check.length; i++) {   
	   if(all_check[i].checked) count_check++;
		
	}  
	if(count_check==0){
	alert("Please select atleast one option Critical Village (quality) ");
	return false;
	}
	
	
	var all_check = document.getElementsByName("CH_quantity[]");
	count_check=0;
	for (var i = 0; i < all_check.length; i++) {   
	   if(all_check[i].checked) count_check++;
		
	}  
	if(count_check==0){
	alert("Please select atleast one option Critical Village (quantity) ");
	return false;
	}
}


}

</script>
</head>
<body>
<form action="critical_edit_q2.php" method="post" name="sec11" id="sec11" onSubmit="return sec6_val();">
<table border="0" width="687" id="table2" bgcolor="#EEEEEE" cellspacing="1" cellpadding="0">
					<tr>
						<!--<td colspan="5">
							<span style="font-size: 4pt">&nbsp;</span>
						</td>-->
						<td width="432" height="36" align="left"  bgcolor="#CCCCCC">&nbsp;
							<font face="Verdana" style="font-size: 8.5pt" color="#000000">
							<b>Critical Habitation</b></font></td>
					</tr>
					<?php
					$sql_crit="select * from tbl_dtls_q2_critical where id=$critical_vill_id";
					$query_crit=mysql_query($sql_crit);
					$row_crit=mysql_fetch_array($query_crit);
					$frm=$row_crit['q2_id'];
					?>
				<tr align="center">
				   <td width="432">
				  <font style="font-size: 9pt" face="Verdana" color="#000000">
				  <input type="hidden" name="frmId" id="frmId" value="<?php echo $frm;?>" />
	  <input type="hidden" name="loginId" id="loginId" value="<?php echo $loginId;?>" />
	  <input type="hidden" name="name" id="name" value="<?php echo $name;?>" />
	  <input type="hidden" name="userType" id="userType" value="<?php echo $userType;?>" />
				  <input type="hidden" name="critical_id" id="critical_id" value="<?php echo $row_crit['id'];?>">
				  <input type="radio" name="critical" id="critical_yes" value="yes" <?php echo($row_crit['critical']=='yes')?'checked':'';?> onClick="show_critical(this.value)">Yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	  		  	  <input type="radio" name="critical" id="critical" value="no" <?php echo($row_crit['critical']=='no')?'checked':'';?> onClick="show_critical(this.value)">No&nbsp;</font></td>
				</tr> 
					<tr>
						
						
						<td>
						<?php
						if($row_crit['critical']=='yes')
						{
						$prop="block";
						$props="none";
						}else{
						$props="block";
						$prop="none";
						}
						?>
						<div id="crits" style="display:<?php echo $props;?>; height:50px; padding-top:20px" align="center">
						<input type="submit" value="OK" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px; font-weight:bold; background:#666666; color:#FFFFFF; width:50px; height:25px" onClick="view_validate()">
						</div>
						<div id="crit" style="display:<?php echo $prop;?>">
						
							<table border="0" width="100%" id="table16" cellpadding="0">
							<tr>
								<td height="22" colspan="5">
								<font face="Verdana" style="font-size: 8.5pt" color="#990000">&nbsp; 
								Critical Village in terms of quality </font>							                        		</td>
							</tr>
							<tr>
								<td width="93" height="24">&nbsp;
								<?php
								$quality=explode(',',$row_crit['CH_quality']);
								?>
								<!--<input type="checkbox" name="exist_water_supplied[]" id="exist_water_supplied[]" value="bulk_meters"<?php //echo  (in_array('bulk_meters',$exist_means)?'checked':'');?>>-->
					  	   		<input type="checkbox" name="CH_quality[]" id="CH_quality[]" value="Fluoride"<?php echo  (in_array('Fluoride',$quality)?'checked':'');?>>
						  		<font face= "Verdana" style="font-size: 8.5pt" color="#000000">                           		Fluoride </font> </td>
				    		  <td width="87"><input type="checkbox" name="CH_quality[]" id="CH_quality[]" value="Nitrates"<?php echo  (in_array('Nitrates',$quality)?'checked':'');?>>
			    		      <font face= "Verdana" style="font-size: 8.5pt" color="#000000"> Nitrates</font> </td>
					    		<td width="61">
				 	    		<input type="checkbox" name="CH_quality[]" id="CH_quality[]" value="TDS"<?php echo (in_array('TDS',$quality)?'checked':'');?>><font style="font-size: 8.5pt" face="Verdana" color="#000000">TDS</font> </td>
					    		<td width="98">
						  		<input type="checkbox" name="CH_quality[]" id="CH_quality[]" value="Salinity"<?php echo (in_array('Salinity',$quality)?'checked':'');?>> 
					  	  		<font style="font-size: 8.5pt" face="Verdana" color="#000000">Salinity                          		</font></td>
								
						      <td width="81"><input type="checkbox" name="CH_quality[]" id="CH_quality[]" value="None"<?php echo (in_array('None',$quality)?'checked':'');?>><font style="font-size: 8.5pt" face="Verdana" color="#000000">None</font></td>
							</tr>
							<tr>
								<td height="26" colspan="5">&nbsp;
								<font face="Verdana" style="font-size: 8.5pt" color="#990000">
								Critical Village in terms of quantity </font>            						                       			</td>
							</tr>
							<tr>
								<td height="26" colspan="2">&nbsp;&nbsp;
								<?php
								$quantity=explode(',',$row_crit['CH_quantity']);
								?>
								<input type="checkbox" name="CH_quantity[]" id="CH_quantity[]" value="Non Availability of water"<?php echo (in_array('Non Availability of water',$quantity)?'checked':'');?>><font style="font-size: 8.5pt" face="Verdana" color="#000000">&nbsp;Non Availability of water in habitation</font></td>
					    		<td height="26" colspan="3"><input type="checkbox" name="CH_quantity[]" id="CH_quantity[]" value="Insufficient quantity of water"<?php echo (in_array('Insufficient quantity of water',$quantity)?'checked':'');?>><font style="font-size: 8.5pt" face="Verdana" color="#000000"> Insufficient quantity of water to meet minimum demand</font></td>
				    		</tr>
							<tr>
								<td height="40" colspan="2">
							  &nbsp;
							  <input type="checkbox" name="CH_quantity[]" id="CH_quantity[]" value="Emergency response system"<?php echo (in_array('Emergency response system',$quantity)?'checked':'');?>>
							  <font style="font-size: 8.5pt" face="Verdana" color="#000000">&nbsp;Emergency response &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system</font> </td>
					    		<td height="40" colspan="3"><input type="checkbox" name="CH_quantity[]" id="CH_quantity[]" value="Excess drawal of water"<?php echo (in_array('Excess drawal of water',$quantity)?'checked':'');?>><font style="font-size: 8.5pt" face="Verdana" color="#000000"> Excess drawal of water by intermediate habitation</font></td>
				    		</tr>
							<tr>
								<td height="48" colspan="2">
								&nbsp;&nbsp;<input type="checkbox" name="CH_quantity[]" id="CH_quantity[]" value="None"<?php echo (in_array('None',$quantity)?'checked':'');?>><font style="font-size: 8.5pt" face="Verdana" color="#000000">&nbsp;None</font></td>
				    		</tr>
							 <tr>
	    <td height="64" colspan="2" align="center"><input type="submit" value="EDIT" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px; font-weight:bold; background:#666666; color:#FFFFFF; width:140px; height:30px" onClick="view_validate()"></td>
  </tr>
						</table>
						
						</div>
						
						</td>
				</tr>
				
			</table></form>
</body>
</html>